package jinf

import "fmt"

// interface definition
type VowelsFinder interface {
	FindVowels() []rune
}

// ? TODO
type MyString string

// 传入 MyString 采用 VowelsFinder 相同的 方法 FindVowels 方法
func (myStr MyString) FindVowels() []rune {
	var vowels []rune
	for index, rune := range myStr {
		fmt.Printf("index: %v \n", index)
		if inRune(rune) {
			fmt.Printf("rune: %v \n", rune)
			vowels = append(vowels, rune)
		}
	}
	return vowels
}

func inRune(rune int32) bool {
	return rune == 'a' || rune == 'e' || rune == 'i' || rune == 'o' || rune == 'u'
}

func main() {
	name := MyString("hello i am json !")
	var v VowelsFinder
	v = name
	fmt.Printf(" v.FindVowels() rel is : %c", v.FindVowels())

	//name := MyString("hello i am json !")
	var v2 VowelsFinder = MyString("hello i am json ,who u are !")
	fmt.Printf(" v2.FindVowels() rel is : %c", v2.FindVowels())
}
